/*
 * Course:    CS 590 Web Services
 * Semseter:  Spring 2009
 * Professor: Sedlemeyer
 * Project:   CHEAT (Code Help Educational Assignment Tool)
 * Due Date:  May 1, 2009
 * Team:      Sarcasm
 *            (Baker, Jason; Mitchell, Robin; Shie, Keith)
 */
package cheat.entities.keys;


import cheat.entities.AssignmentCustomProperty;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;


/**
 * Holds the composite primary key for the {@linkplain AssignmentCustomProperty} entity.
 *
 * @author Keith Shie
 */
@Embeddable
public class AssignmentCustomPropertyPK implements Serializable {

  @Basic( optional = false )
  @Column( name = "uuid", nullable = false )
  private int uuid;
  @Basic( optional = false )
  @Column( name = "prop_name", nullable = false, length = 20 )
  private String name;


  public AssignmentCustomPropertyPK() {
  }


  public AssignmentCustomPropertyPK( int uuid, String propName ) {
    this.uuid = uuid;
    this.name = propName;
  }


  public int getUuid() {
    return uuid;
  }


  public void setUuid( int uuid ) {
    this.uuid = uuid;
  }


  public String getName() {
    return name;
  }


  public void setName( String name ) {
    this.name = name;
  }


  @Override
  public int hashCode() {
    int hash = 0;
    hash += (int) uuid;
    hash += ( name != null ? name.hashCode() : 0 );
    return hash;
  }


  @Override
  public boolean equals( Object object ) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if ( !( object instanceof AssignmentCustomPropertyPK ) ) {
      return false;
    }
    AssignmentCustomPropertyPK other = (AssignmentCustomPropertyPK) object;
    if ( this.uuid != other.uuid ) {
      return false;
    }
    if ( ( this.name == null && other.name != null ) || ( this.name != null && !this.name.equals( other.name ) ) ) {
      return false;
    }
    return true;
  }


  @Override
  public String toString() {
    return "cheat.entities.AsgnCustPropPK[uuid=" + uuid + ", propName=" + name + "]";
  }
}
